$(function () {
	// body...
    localStorage.indexName = titleIndex;



    $.ajax({
        url: 'http://47.89.20.150/czlycms/index.php?m=Web&a=getStock',
        type: 'GET',
        dataType: 'JSONP'
    })
    .done(function(data) {
        console.log("success");
        console.log(data);
        $('#STOCK_word').find('.Lw').find('.p2').text(data.time);
        $('#STOCK_word').find('.Rw').find('.p1').text('HK＄'+data.g_price);
        $('#STOCK_word').find('.Rw').find('.p2').text(isIfFun(data.isUp)+data.stock1+' | '+isIfFun(data.isUp)+data.stock2);
        function isIfFun(data){
            if (data >0) {
                return '+ ';
            }else if(data < 0){
                return '- ';
            }else if (data == 0) {
                return ' ';
            }
        }

    })
    .fail(function() {
        console.log("error");
    });


	$.ajax({
        url: 'http://47.89.20.150/czlycms/index.php?m=Web&a=investors',
        type: 'GET',
        dataType: 'JSONP'
    })
    .done(function(data) {
        console.log("success");
        console.log(data);
      investor_newsFun(data.investor_news);
      financial_informationFun(data.financial_information);
      publicationsFun(data.publications);
        
    })
    .fail(function() {
        console.log("error");
    })
    .always(function() {
        console.log("complete");
    });
})










// investor_news
function investor_newsFun(data){
    var dari = ['Jan','Feb','Mar','Apr','May','Jun','Jul','Aug','Sep','Oct','Nov','Dec'];
    var investorList = $('#investorList');
    var html = '';


    for (var i = 0; i < data.length; i++) {
        var cn = '<li ><a href="article.html?article_id='+data[i].article_id+'" class="clearfloat"><div class="imgC"><img src="'+data[i].image_url+'"></div><div class="Wr"><h3>'+data[i].title+'</h3><p>'+data[i].seo_description+' </p><div class="time">'+dari[((data[i].issueDate.split("-"))[1])-1]+' '+(data[i].issueDate.split("-"))[2]+', '+(data[i].issueDate.split("-"))[0]+'</div></div></a></li>';
        html += cn;
    }

    investorList.html(html);
}

// investor_news end


// investor_news
function financial_informationFun(data){
    var FinancialLsCn = $('#FinancialLsCn');
    var icon = ['&#xe644;','&#xe644;'];
    var html = '';


    for (var i = 0; i < data.length; i++) {
        var cn = '<li>'+
                    '<div class="Cn">'+
                        '<div class="Cnbr">'+
                            '<div class="Hd">'+data[i].title+'</div>'+
                            '<div class="icnoC"><i class="iconfont">'+icon[i]+'</i></div>'+
                            '<p>'+data[i].describe+'</p>'+
                       ' </div>'+
                    '</div>'+
                    '<div class="Download"><a href="'+data[i].image_url+'" title="Download">Download</a></div>'+
                '</li>';
        html += cn;
    }

    FinancialLsCn.html(html);
}

// investor_news end


// publications
function publicationsFun(data){
     var PublicationslsCn = $('#PublicationslsCn');
    // var icon = ['&#xe62e;','&#xe62d;','&#xe631;','&#xe632;'];
    var icon = ['&#xe640;','&#xe640;','&#xe640;','&#xe640;'];
    var html = '';


    for (var i = 0; i < data.length; i++) {
        var cn = '<li>'+
                    '<a href="'+data[i].image_url+'">'+
                        '<div class="Hd">'+data[i].title+'</div>'+
                        '<div class="iconC"><i class="iconfont">'+icon[i]+'</i></div>'+
                        '<p>'+data[i].describe+'</p>'+
                    '</a>'+
                '</li>';
        html += cn;
    }

    PublicationslsCn.html(html);
}
// publications end
